package com.qinglei.recoup.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qinglei.recoup.common.domain.CommonRes;
import com.qinglei.recoup.system.pojo.NurseWorkSearchParam;
import com.qinglei.recoup.system.pojo.NurseWorkVO;
import com.qinglei.recoup.system.service.EventProcService;
import com.qinglei.recoup.system.service.NurseStatisticsService;
import com.qinglei.recoup.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Api(tags = "数据统计相关控制器-张-已完成")
@Slf4j
@Validated
@RestController
@RequestMapping("statis")
public class StatisticsController {

    @Resource
    private NurseStatisticsService nurseStatisticsService;

    @ApiOperation(value = "获取护工工效数据列表-已完成（二期改）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "查询类型 1-今天 2-昨天 3-7天 4-30天", paramType = "query", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageNum", value = "当前页码，从1开始，默认是1", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数，默认20", paramType = "query", dataType = "Integer")
    })
    @GetMapping("/nurseWork")
    public CommonRes<IPage<NurseWorkVO>> getNurseWork(NurseWorkSearchParam searchParam) {
        IPage<NurseWorkVO> nurseWorkVOIPage = nurseStatisticsService.searchNurseWorkPage(searchParam);
        return CommonRes.ok(nurseWorkVOIPage);
    }

    /**
     * 浏览器导出护工工效数据列表(二期)
     *
     * @param httpServletResponse
     */
    @ApiOperation(value = "浏览器导出护工工效数据列表(二期)")
    @GetMapping("/export")
    public void export(HttpServletResponse httpServletResponse, @Valid NurseWorkSearchParam param) {
        nurseStatisticsService.exportNurseWork(httpServletResponse, param);
    }
}
